let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active:0,
    refundId:null,
    refundDetail:{},
    steps: [],
    imgPath: app.globalData.imgPath,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if((options.refundId??'') !== '') {
      this.setData({
        refundId: Number(options.refundId)
      })
      this.refundDetail();
    }

    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },
  refundDetail() {
    let urlStr = app.getNetAddresss("refund.detail");
    let json = {
      refund_id:this.data.refundId,
    };
    app._getNetWork({
      url: urlStr,
      data:json,
      success:  (resdata) => {
        let res = resdata.data;
        if (res.result == 1) {
          let refundDetail = res.data;
          let steps = [];
          let active = 0;
          if(refundDetail.create_time) {
            steps.push({
              text:'申请退款',
              desc: refundDetail.create_time
            })
            steps.push({
              text:'退款成功',
              desc: ''
            })
            
          }
          if(refundDetail.refund_time) {
            steps[1].desc = refundDetail.refund_time;
            active = 1;
          }
          if(refundDetail.reject_time) {
            steps[1].text = '申请驳回';
            steps[1].desc = refundDetail.reject_time;
            active = 1;
          }
          this.setData({
            refundDetail,
            steps,
            active
          })
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  }, 
  copyCode(event) {
    let text = event.currentTarget.dataset.text;
    console.log(text);
    wx.setClipboardData({
      data: text,
      success: function (res) {
        wx.getClipboardData({
          //这个api是把拿到的数据放到电脑系统中的
          success: function (res) {
            wx.showToast({
              title: '复制成功'
            });
            
          }
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})